//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;

namespace CommunityServer.Components
{
	/// <summary>
	/// Basic data structure for Ink content. This object is not tied to a particular post 
	/// which means not only can it be shared across posts but each post can contain more 
	/// than one InkData
	/// </summary>
	public class InkData
	{
		public InkData()
		{
		}

		private int _inkid, _sectionid, _userid;
		private string _inkData;
		private DateTime  _dateupdated;
		private ApplicationType _appType;
        const string undefined = "undefined";

		public int InkID
		{
			get{return _inkid;}
			set{_inkid = value;}
		}

		public int SectionID
		{
			get{return _sectionid;}
			set{_sectionid = value;}
		}

		public int UserID
		{
			get{return _userid;}
			set{_userid = value;}
		}

		public string InkString
		{
			get
			{
			    return _inkData;
			}
			set { _inkData = value;}
		}

		public DateTime DateUpdated
		{
			get{ return _dateupdated;}
			set {_dateupdated = value;}
		}

		public ApplicationType ApplicationType
		{
			get{ return _appType;}
			set {_appType = value;}
		}

		public byte[] GetBytes()
		{
			if(IsEmpty)
				return null;

			return Convert.FromBase64String(this.InkString);
		}


        public bool IsEmpty
        {
            get { return Globals.IsNullorEmpty(this.InkString) || this.InkString == undefined;}
        }

		public string Url
		{
			get
			{
				return Globals.FullPath(Globals.GetSiteUrls().Ink(this));
			}
		}
	}
}